package com.qidianit.mes.pro.controller;

import com.qidianit.mes.common.Result;
import com.qidianit.mes.pojo.pro.WorkFlow;
import com.qidianit.mes.pro.service.WorkFlowService;
import com.qidianit.mes.vo.WorkFlowPageVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Package Path: com.qidianit.mes.pro.controller
 * Author: Alhz
 * Description:
 * Date: 2025/9/17 16:43
 */
@RestController
@RequestMapping("/workflow")
public class WorkFlowController {
    @Resource
    private WorkFlowService workFlowService;

    /**
     * 分页查询工艺流程
     * @param workFlowPageVo
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/page")
        public Result selectWorkFlowPage(WorkFlowPageVo workFlowPageVo,
                                         @RequestParam(defaultValue = "1") int page,
                                         @RequestParam(defaultValue = "10") int pageSize){
        return workFlowService.selectWorkFlowPage(workFlowPageVo, page, pageSize);
    }

    /**
     * 根据工艺编号查询单个工艺信息
     * @param code
     * @return
     */
    @GetMapping("/code/{code}")
    public Result selectWorkFlowByCode(@PathVariable String code){
        return workFlowService.selectWorkFlowByCode(code);
    }

    /**
     * 新增工艺流程
     * @param workFlow
     * @return
     */
    @PostMapping("/add")
    public Result addWorkFlow(@RequestBody WorkFlow workFlow){
        return workFlowService.addWorkFlow(workFlow);
    }

    /**
     * 编辑工艺流程
     * @param workFlow
     * @return
     */
    @PutMapping("/update")
    public Result updateWorkFlow(@RequestBody WorkFlow workFlow){
        return workFlowService.updateWorkFlow(workFlow);
    }

    /**
     * 根据id删除工艺流程
     * @param id
     * @return
     */
    @DeleteMapping("/delete/{id}")
    public Result deleteWorkFlowById(@PathVariable Long id){
        return workFlowService.deleteWorkFlowById(id);
    }

    /**
     * 批量删除工艺流程
     * @param id
     * @return
     */
    @DeleteMapping("/batchDelete")
    public Result batchDeleteWorkFlow(Long[] id){
        return workFlowService.batchDeleteWorkFlow(id);
    }



}
